package com.woniuxy.house.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ConcernMapper {
    /**
     * 添加帖子关注
     *
     * */
    @Insert("insert into house_user_post(user_id,post_id) values(#{userId},#{postId})")
    void addPostConcern(@Param("userId") Integer userId,@Param("postId") Integer postId);

    /**
     * 查询用户所有关注的帖子ID
     * */

    @Select("select post_id from house_user_post where user_id=#{id}")
    List<Integer> getPostConcernByUserId(Integer userId);

    /**
     * 根据用户ID和帖子ID取消用户对该帖子的关注
     *
     * */

    @Delete("delete from house_user_post where user_id=#{userId} and post_id=#{postId}")
    void deletePostConcernByUserIdAndPostId(@Param("userId") Integer userId,@Param("postId") Integer postId);

}
